﻿<UserControl x:Class="HelpDesk.UserControls.MainWindowUser"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:HelpDesk"
             xmlns:AmmasoConverts="clr-namespace:AmmasoConverts;assembly=AmmasoConverts"
             xmlns:local="clr-namespace:WPFAutoCompleteTextbox"
             xmlns:my="clr-namespace:HelpDesk.Commands"
             xmlns:ViewModel="clr-namespace:HelpDesk.ViewModel"
             xmlns:UserControls="clr-namespace:HelpDesk.UserControls"
             xmlns:AmmasoWpfUsersControl="clr-namespace:AmmasoWPFUsersControls;assembly=AmmasoWPFUsersControls"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300">

    <UserControl.Resources>
        <AmmasoConverts:BoolToVisibility x:Key="BoolToVisibility" />
        <AmmasoConverts:StringToEnable x:Key="StringToEnable" />
        <AmmasoConverts:NullOrEmptyToVisibility x:Key="NullOrEmptyToVisibility" />
    </UserControl.Resources>
    <UserControl.DataContext>
        <ViewModel:MainWindowUserViewModel MessageBus="{StaticResource APPMessageBus}" />
    </UserControl.DataContext>
    <Grid>
        <StackPanel x:Name="StackPanelUsers"
                    Grid.Row="1"
                    Grid.Column="1">
            <Grid Height="36"
                  Margin="10,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="82" />
                    <ColumnDefinition Width="68*" />
                    <ColumnDefinition Width="25*" />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Margin="0,8,10,38"
                           Text="User Name" />
                <ComboBox x:Name="txt_UserName"
                          Margin="0,3,0,38"
                          Grid.Row="0"
                          Grid.Column="1"
                          ToolTip="User name autocomplete from ad"
                          IsEditable="True"
                          ItemsSource="{Binding TxtUsersNames}"
                          SelectedItem="{Binding SelectedItemUser}"
                          DisplayMemberPath="SamAccountName"
                          SelectedValuePath="SamAccountName" />
                <StackPanel Orientation="Horizontal"
                            Grid.Column="2"
                            Margin="5,3,0,38">
                    <!--Visibility="{Binding Text, Converter={StaticResource NullOrEmptyToVisibility}, ElementName=TxtUsersNamesCount}"-->
                    <AmmasoWpfUsersControl:CircularProgressBar Height="10"
                                                               VerticalAlignment="Center"
                                                               HorizontalAlignment="Center"
                                                               Visibility="{Binding Text, Converter={StaticResource NullOrEmptyToVisibility},ElementName=TxtUsersNamesCount}"
                                                               RenderTransformOrigin="0.6,0" />

                    <TextBlock Text="{Binding TxtUsersNamesCount}"
                               VerticalAlignment="Center"
                               HorizontalAlignment="Center"
                               Name="TxtUsersNamesCount" />
                </StackPanel>

            </Grid>
            <StackPanel Margin="10,0,0,0"
                        Grid.Column="1"
                        Grid.Row="1"
                        Orientation="Horizontal"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Width="204"
                        Visibility="Collapsed"
                        IsEnabled="{Binding Text, Converter={StaticResource StringToEnable}, ElementName=txt_UserName}">
                <StackPanel>
                    <Button Grid.Row="1"
                            Height="28"
                            x:Name="btn_UserDesktop"
                            Content="Desktop"
                            Width="75"
                            Grid.Column="1"
                            Margin="0,5,5,0" />
                    <Button Grid.Row="1"
                            Height="28"
                            x:Name="btn_UserHomeDrive"
                            Content="HomeDrive"
                            Width="75"
                            Grid.Column="1"
                            Margin="0,5,5,0" />
                    <Button Grid.Row="1"
                            Height="28"
                            x:Name="btn_UserUnLock"
                            Content="UnLock"
                            Width="75"
                            Grid.Column="1"
                            Margin="0,5,5,0"
                            Visibility="{Binding IsAccountLockedOut, Converter={StaticResource BoolToVisibility}}" />
                </StackPanel>
                <!--<StackPanel>
                    <TextBlock Name="computerCount" Width="50"></TextBlock>
                    <TextBlock Name="userCount" Width="50"></TextBlock>
                    <TextBlock Name="printerCount" Width="50"></TextBlock>
                </StackPanel>-->
            </StackPanel>
            <ListBox Margin="10,0,0,0"
                     Grid.Column="1"
                     Grid.Row="1"
                     ItemsSource="{Binding RemoteSoftwares}"
                     IsEnabled="{Binding Text, Converter={StaticResource StringToEnable}, ElementName=txt_UserName}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Vertical"
                                   IsItemsHost="True"
                                   Height="200" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>

            </ListBox>
            <Border Margin="10,10,0,0"
                    BorderBrush="Black"
                    CornerRadius="1"
                    BorderThickness="1">
                <Grid DataContext="{Binding SelectedItem, ElementName=txt_UserName}"
                      Height="63.84"
                      Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="17*" />
                        <RowDefinition Height="16*" />
                        <RowDefinition Height="15*" />
                        <RowDefinition Height="16*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="49*" />
                        <ColumnDefinition Width="50*" />
                    </Grid.ColumnDefinitions>
                    <StackPanel Orientation="Horizontal"
                                Margin="0,0,0,1"
                                Grid.ColumnSpan="2">

                    </StackPanel>
                    <TextBlock Text="First Name:" />
                    <TextBlock Grid.Column="1"
                               Text="{Binding GivenName}"
                               HorizontalAlignment="Right" />

                    <TextBlock Text="Last Name:"
                               Grid.Row="1" />
                    <TextBlock Text="{Binding Surname}"
                               Grid.Row="1"
                               Grid.Column="1"
                               HorizontalAlignment="Right" />

                    <TextBlock Text="Employee Id:"
                               Grid.Row="2" />
                    <TextBlock Grid.Column="1"
                               Grid.Row="2"
                               HorizontalAlignment="Right"
                               Text="{Binding EmployeeId}"
                               FontWeight="Bold" />

                    <TextBlock Text="Is Account Locked Out:"
                               Grid.Row="3"
                               IsEnabled="{Binding IsAccountLockedOut}"
                               Visibility="{Binding IsAccountLockedOut, Converter={StaticResource BoolToVisibility}}">
                    </TextBlock>
                    <TextBlock Text="{Binding IsAccountLockedOut}"
                               HorizontalAlignment="Right"
                               Grid.Row="3"
                               Grid.Column="1"
                               Visibility="{Binding IsAccountLockedOut, Converter={StaticResource BoolToVisibility}}">
                    </TextBlock>



                </Grid>
            </Border>
        </StackPanel>
    </Grid>
</UserControl>
